package com.google.code.jholidays.events.properties;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;

import java.util.Calendar;

import org.junit.Test;

import com.google.code.jholidays.core.EventDescriptor;
import com.google.code.jholidays.events.parameters.DateParameters;
import com.google.code.jholidays.events.parameters.DayOfWeekOrder;

public class FloatingEventPropertiesTest {

    @Test(expected = IllegalArgumentException.class)
    public void testNullDescriptor() {

	DateParameters dateParams = new DateParameters(1, Calendar.JANUARY,
		DayOfWeekOrder.First);

	FloatingEventProperties props = new FloatingEventProperties(null,
		dateParams);
	assertNull(props);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testNullDateParams() {
	int eventID = 2;

	EventDescriptor descriptor = new EventDescriptor(eventID);

	FloatingEventProperties props = new FloatingEventProperties(descriptor,
		null);
	assertNotNull(props);
    }

    @Test
    public void testGetDateParameters() {
	int eventID = 2;

	EventDescriptor descriptor = new EventDescriptor(eventID);

	DateParameters dateParams = new DateParameters(1, Calendar.JANUARY,
		DayOfWeekOrder.First);

	FloatingEventProperties props = new FloatingEventProperties(descriptor,
		dateParams);
	assertNotNull(props);

	assertSame(dateParams, props.getDateParameters());
    }

    @Test
    public void testGetDescriptor() {
	int eventID = 2;

	EventDescriptor descriptor = new EventDescriptor(eventID);

	DateParameters dateParams = new DateParameters(1, Calendar.JANUARY,
		DayOfWeekOrder.First);

	FloatingEventProperties props = new FloatingEventProperties(descriptor,
		dateParams);
	assertNotNull(props);

	assertSame(descriptor, props.getDescriptor());
    }

    @Test
    public void testGetParentIsAlwaysNull() {
	int eventID = 2;

	EventDescriptor descriptor = new EventDescriptor(eventID);

	DateParameters dateParams = new DateParameters(1, Calendar.JANUARY,
		DayOfWeekOrder.First);

	FloatingEventProperties props = new FloatingEventProperties(descriptor,
		dateParams);
	assertNotNull(props);

	assertSame(null, props.getParent());
    }
}
